package com.mi9688.stream;

import com.mi9688.default_method.MyInterfaceByJava8;
import com.mi9688.lambda.Student;

import java.util.ArrayList;
import java.util.Arrays;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.function.IntConsumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;


public class ListToMap {
	public static void main(String [] args){
		List<Student> students=Arrays.asList(new Student("小明",18),new Student("小黑",16),new Student("小红",17));
		//转成Stream
		Stream<Student> stream=students.stream();
		//转Map
		Map<String,Student> map=stream.collect(Collectors.toMap(student->student.getName(), student->student));
		//遍历
		map.forEach((key,value)->System.out.println(key+"--"+value));



	}
}
